package com.example.osstest.controller;

import com.example.osstest.service.LocalFileUploadService;
import com.example.osstest.vo.FileUploadResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@RestController
@RequestMapping("local")
public class LocalFileUploadController {
    @Autowired
    private LocalFileUploadService localFileUploadService;

    /**
     * @desc 文件上传到本地
     * @param files
     * @return
     * @throws Exception
     */
    @RequestMapping("upload")
    @ResponseBody
    public FileUploadResult[]  upload(HttpServletRequest request,
            @RequestParam("file")MultipartFile[] files)
            throws IllegalStateException,IOException {

        return this.localFileUploadService.upload(request,files);
    }


}
